<template>
  <RouterView />
</template>

<script setup>
import { RouterView, useRouter } from 'vue-router';
import { parseUrlParams } from '@/utils/param';
import UseAppStore from '@/store/modules/app';

const router = useRouter();
const appStore = UseAppStore();
const initData = parseUrlParams(window.Telegram.WebApp.initData);

appStore.setInitData(initData);

window.Telegram.WebView.onEvent('back_button_pressed', data => {
  router.back();
  
  setTimeout(() => {
    if (location.pathname != "/") {
      window.Telegram.WebApp.BackButton.show();
    } else {
      window.Telegram.WebApp.BackButton.hide();
    }
  }, 0);

});
</script>

